package objexc;

public class GoodsTest {
    public static void main(String[] args) {
        //创建数组
        Goods[] arr = new Goods[3];
        //创建三个对象
        Goods g1=new Goods("001","华为p40",5999,100);
        Goods g2=new Goods("002","手表",199,50);
        Goods g3=new Goods("003","平板",7999,80);
        //商品添加到数组
        arr[0]=g1;
        arr[1]=g2;
        arr[2]=g3;
        //遍历
        for (int i = 0; i < arr.length; i++) {
            Goods goods = arr[i];
            System.out.println(goods.getId() + ", "
                    + goods.getName() + ", " + goods.getPrice() + ", "
                    + goods.getCount());
        }

    }
}
